<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/vectrics.tld" prefix="vectrics" %>


<%@ page import="org.vectrics.recruiter.config.*" %>
<%@ page import="org.vectrics.hibernate.ThreadProperties" %>
<%@ page import="org.vectrics.domain.Domain" %>

<%
	Domain domain = ThreadProperties.getDomain();
	String domainId = ThreadProperties.getDomain().getId().toString();
	String uriDomainId = ThreadProperties.getUriDomainId();

	String emailPasswordHref = "/hrs-public/public/" + uriDomainId + "/getEmailAddress.do";
	String newUserHref = "/hrs-public/public/" + uriDomainId + "/new_user.do?new=true&showUserName=y";
	boolean hasCandidateModule =  RecruitConfig.getRecruitInstance().getModuleCandidatePublicSite(domain);
%>

<%
	if (hasCandidateModule) {
%>
	<%
		String newUserParam = request.getParameter("newUser");
			boolean newUser = false;
			if (newUserParam != null)
		newUser = true;
	%>
	
	<%
			if (newUser) {
		%>
		<p class="errorFont"><bean:message key="prompt.login.account.est"/></p>
	<%
		}
	%>
	
		
		
	<%
							if (request.getParameter("error") != null) {
						%>
		<p class="errorFont"><bean:message key="prompt.login.bad"/></p>
	<%
		}
	%>	
	
	<form method="post" name="fm" action="submitCredentials.do" id="login.form">
		<%
			if (request.getParameter("error") != null) {
		%>
			<input type="hidden" name="loginRetry" value="true"/>
		<%
			}
		%>	
		<input type="hidden" name="domainId" value="<%=domainId%>"/>
		
		<input type="hidden" name="login" value="on"/>
		<table cellpadding="1" cellspacing="0" width="60%">
				<tr>
					<td valign="top">
						<font class="formLabelClass"><bean:message key="prompt.user.name"/></font>
						</td>
					<td valign="top">
						<input value="" class="formEditClass" name="username" type="text">
						</td>
				</tr>
				<tr>
					<td valign="top">
						<font class="formLabelClass"><bean:message key="prompt.password"/></font>
						</td>
					<td valign="top">
						<input value="" class="formEditClass" name="password" type="password">
						</td>
				</tr>
				<tr>
					<td valign="TOP" align="left"></td>
					<td valign="TOP" align="left">
						<vectrics:formButton code="public.button.ok" phraseCode="button.login" value="submit" name="submit"/>
					</td>
				</tr>
		</table>
	</form>
	<a class="stdLink" href="<%=newUserHref%>">New Member</a>
	
	
	<%
				boolean allowEmailPassword = RecruitConfig.getRecruitInstance().getAllowPasswordEmail(domain);
					if (allowEmailPassword) {
			%>
			<br><br>
			<a class="stdLink" href="<%=emailPasswordHref%>">E-Mail me my password</a>
	<%  } %>
	
	
	<script type="text/javascript" language="JavaScript">
	  <!--
	  var focusControl = document.forms["fm"].elements["username"];
	
	  if (focusControl.type != "hidden") {
	     focusControl.focus();
	  }
	  -->
	</script>
<% } else { %>
	<h1>Attempt to access secured page refused.</h1>
<% } %>
